package com.wuxin.ssm.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuxin.ssm.entity.*;
import com.wuxin.ssm.mapper.OrderdetailMapper;
import com.wuxin.ssm.mapper.XmorderMapper;
import com.wuxin.ssm.service.OrderdetailService;
import com.wuxin.ssm.vo.OrderdetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @program: ssmwork
 * @ClassName OrderdetailServiceImpl
 * @description:
 * @author: 李尧坤
 * @create: 2024−12-24 09:28
 * @Version 1.0
 **/
@Service
public class OrderdetailServiceImpl implements OrderdetailService {

    @Autowired
    private OrderdetailMapper  orderdetailMapper;

    @Autowired
    private XmorderMapper xmorderMapper;


    @Override
    public List<Orderdetail> dingdanxiangqing(String oid) {
        List<Orderdetail> orderdetails = orderdetailMapper.selectByOid(oid);
        return orderdetails;
    }

    @Override
    public PageInfo splitPage(Integer page, int pageSize) {
        //对象是空的
        OrderdetailExample example = new OrderdetailExample();
        //使用分页 必须先设置这个方法
        PageHelper.startPage(page,pageSize);
        //查询所有数据
        List<Orderdetail> orderdetailList = orderdetailMapper.selectAll(example);
        //将集合交给分页类
        PageInfo<Orderdetail> pageInfo= new PageInfo<Orderdetail>(orderdetailList);

        return pageInfo;
    }


    @Override
    public PageInfo chaxun(Integer page, int pageSize, OrderdetailVo ordervo) {
        //使用分页 必须先设置这个方法
        PageHelper.startPage(page,pageSize);

        List<Orderdetail> orderdetailsList = xmorderMapper.selectxmorder(ordervo);

        //将集合交给分页类
        PageInfo<Orderdetail> pageInfo= new PageInfo<Orderdetail>(orderdetailsList);

        return pageInfo;
    }
}
